var tool={}
let that
tool.install= function (Vue, options) {
    Vue.prototype.$tool = tool
    Vue.tool = tool
    that= Vue.prototype
  }
//定义后端路径前缀
tool.afterUrlPre="http://localhost:8080/"
//定义前端路径前缀
tool.beforeUrlPre="http://localhost:8081/#"

//that：this  msg:消息  fun：回调函数  args参数数组
tool.confirm=function confirm(msg,fun,args){
    that.$confirm(msg)
      .then(() => {
        fun().apply(that,args)
        done()
      }).catch((e)=> {console.log(e)});
}
//axios封装
tool.axios=function axios(url,data,fun,method){
  if(url[0]==="/"){
    url=url.substring(1)
  }
  method=method?method:"post"
  console.log("发送请求："+tool.afterUrlPre+url)
  that.$axios({
    method: method,
    url: tool.afterUrlPre+url,
    data: data,
}).then((response) => {
  console.log("响应为：")
    console.dir(response)
   fun(response)
  }).catch((error) => {
    console.log(error); //请求失败返回的数据
  });
}
export default tool